//
//  exerciseFile.swift
//  SFQuestion
//
//  Created by liushourun on 2025/10/21.
//

import Foundation


class exerciseFile {
    func reverseList(_ head: ListNode?) -> ListNode? {
        var p = head
        var pre: ListNode? = nil
        while p != nil {
            let next = p?.next
            p?.next = pre
            pre = p
            p = p?.next
        }
        
        return pre
    }
}
